//https://leetcode.cn/problems/missing-two-lcci/
class Solution {
    public int[] missingTwo(int[] nums) {
        // 丢失的数字 + 只出现一次的数字III
        int result = 0;
        for (int i = 1; i <= nums.length + 2; i++)
            result ^= i;
        for (int i = 0; i < nums.length; i++)
            result ^= nums[i];
        int x = result & (-result);
        int[] ret = new int[2];
        for (int n : nums)
            ret[(n & x) == 0 ? 0 : 1] ^= n;
        //别忘了在1~N的整数中再异或一遍
        for (int i = 1; i <= nums.length + 2; i++)
            ret[(i & x) == 0 ? 0 : 1] ^= i;
        return ret;
    }
}